﻿Public Class STK_BulkEntryDialog_Form

    Public iDataObject As DataTable = Nothing



    Private Sub Setup_StockGrid()

        SparesStock_DataGridView.AutoGenerateColumns = False
        SparesStock_DataGridView.Columns.Clear()

        'SpareStockId
        Dim StockItemId_Column As New DataGridViewTextBoxColumn
        With StockItemId_Column
            .DataPropertyName = "StockItemId"
            .Name = "StockItemId_Column"
            .HeaderText = "StockItemId"
            .Visible = False
        End With
        SparesStock_DataGridView.Columns.Add(StockItemId_Column)

        'ItemCode
        Dim ItemCode_Column As New DataGridViewTextBoxColumn
        With ItemCode_Column
            .DataPropertyName = "ItemCode"
            .Name = "ItemCode_Column"
            .HeaderText = "ItemCode"
        End With
        SparesStock_DataGridView.Columns.Add(ItemCode_Column)

        'Description
        Dim Description_Column As New DataGridViewTextBoxColumn
        With Description_Column
            .DataPropertyName = "Description"
            .Name = "Description_Column"
            .HeaderText = "Description"
        End With
        SparesStock_DataGridView.Columns.Add(Description_Column)

        'Category
        Dim Category_Column = New DataGridViewTextBoxColumn
        With Category_Column
            .DataPropertyName = "Category"
            .Name = "Category_Column"
            .HeaderText = "Category"
        End With
        SparesStock_DataGridView.Columns.Add(Category_Column)

        'SubCategory
        Dim SubCategory_Column = New DataGridViewTextBoxColumn
        With SubCategory_Column
            .DataPropertyName = "SubCategory"
            .Name = "SubCategory_Column"
            .HeaderText = "SubCategory"
        End With
        SparesStock_DataGridView.Columns.Add(SubCategory_Column)

        'Model
        Dim Model_Column = New DataGridViewTextBoxColumn
        With Model_Column
            .DataPropertyName = "Model"
            .Name = "Model_Column"
            .HeaderText = "Model"
            .Visible = False
        End With
        SparesStock_DataGridView.Columns.Add(Model_Column)

        'Brand
        Dim Brand_Column = New DataGridViewTextBoxColumn
        With Brand_Column
            .DataPropertyName = "Brand"
            .Name = "Brand_Column"
            .HeaderText = "Brand"
            .Visible = False
        End With
        SparesStock_DataGridView.Columns.Add(Brand_Column)

        'Color
        Dim Color_Column = New DataGridViewTextBoxColumn
        With Color_Column
            .DataPropertyName = "Color"
            .Name = "Color_Column"
            .HeaderText = "Color"
            .Visible = False
        End With
        SparesStock_DataGridView.Columns.Add(Color_Column)

        'Weight
        Dim Weight_Column = New DataGridViewTextBoxColumn
        With Weight_Column
            .DataPropertyName = "Weight"
            .Name = "Weight_Column"
            .HeaderText = "Weight"
            .Visible = False
        End With
        SparesStock_DataGridView.Columns.Add(Weight_Column)

        'Volume
        Dim Volume_Column = New DataGridViewTextBoxColumn
        With Volume_Column
            .DataPropertyName = "Volume"
            .Name = "Volume_Column"
            .HeaderText = "Volume"
            .Visible = False
        End With
        SparesStock_DataGridView.Columns.Add(Volume_Column)

        'Manufacturer
        Dim Manufacturer_Column = New DataGridViewTextBoxColumn
        With Manufacturer_Column
            .DataPropertyName = "Manufacturer"
            .Name = "Manufacturer_Column"
            .HeaderText = "Manufacturer"
            .Visible = False
        End With
        SparesStock_DataGridView.Columns.Add(Manufacturer_Column)

        'Unit
        Dim Unit_Column = New DataGridViewTextBoxColumn
        With Unit_Column
            .DataPropertyName = "Unit"
            .Name = "Unit_Column"
            .HeaderText = "Unit"
            .Visible = False
        End With
        SparesStock_DataGridView.Columns.Add(Unit_Column)

        'Quantity
        Dim Quantity_Column As New DataGridViewTextBoxColumn
        With Quantity_Column
            .DataPropertyName = "Quantity"
            .Name = "Quantity_Column"
            .HeaderText = "Quantity"
            .DefaultCellStyle.Format = "N2"
            .DefaultCellStyle.NullValue = 0
            .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
            .Visible = False
        End With
        SparesStock_DataGridView.Columns.Add(Quantity_Column)

        'CostPrice
        Dim CostPrice_Column As New DataGridViewTextBoxColumn
        With CostPrice_Column
            .DataPropertyName = "CostPrice"
            .Name = "CostPrice_Column"
            .HeaderText = "CostPrice"
            .DefaultCellStyle.Format = "N2"
            .DefaultCellStyle.NullValue = 0
            .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
            .Visible = False
        End With
        SparesStock_DataGridView.Columns.Add(CostPrice_Column)

        'SellingPrice
        Dim SellingPrice_Column As New DataGridViewTextBoxColumn
        With SellingPrice_Column
            .DataPropertyName = "SellingPrice"
            .Name = "SellingPrice_Column"
            .HeaderText = "SellingPrice"
            .DefaultCellStyle.Format = "N2"
            .DefaultCellStyle.NullValue = 0
            .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
            .Visible = False
        End With
        SparesStock_DataGridView.Columns.Add(SellingPrice_Column)

        'TaxPercentage
        Dim TaxPercentage_Column As New DataGridViewTextBoxColumn
        With TaxPercentage_Column
            .DataPropertyName = "TaxPercentage"
            .Name = "TaxPercentage_Column"
            .HeaderText = "TaxPercentage"
            .DefaultCellStyle.Format = "N2"
            .DefaultCellStyle.NullValue = 0
            .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
            .Visible = False
        End With
        SparesStock_DataGridView.Columns.Add(TaxPercentage_Column)

        'UpdateStatus
        Dim UpdateStatus_Column As New DataGridViewTextBoxColumn
        With UpdateStatus_Column
            .DataPropertyName = "UpdateStatus"
            .Name = "UpdateStatus_Column"
            .HeaderText = "UpdateStatus"
            .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        End With
        SparesStock_DataGridView.Columns.Add(UpdateStatus_Column)

    End Sub

    Private Sub STK_BulkEntryDialog_Activated(sender As Object, e As System.EventArgs) Handles Me.Activated
        Setup_StockGrid()
        SparesStock_DataGridView.DataSource = Me.iDataObject
    End Sub

    Private Sub OK_ImageButton_Click(sender As System.Object, e As System.EventArgs) Handles OK_ImageButton.Click
        Me.Close()
    End Sub

    Private Sub SparesStock_DataGridView_DataError(sender As Object, e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles SparesStock_DataGridView.DataError
        'just to avoid data errors from being displayed
    End Sub

End Class